<?php
/**
 * 角色
 * Created by PhpStorm.
 * User: ZengYou
 * Date: 2018/10/13 0013
 * Time: 12:45
 */
namespace app\common\validate;

class AdminRole extends BaseValidate
{

    protected $regex = [];

    protected $rule = [
        'id'           => 'require|number|max:10',
        'name'         => 'require|max:100',
        'ruleId'       => 'require|array',
        'status'       => 'require|in:0,1'
    ];

    protected $message = [
        'id.require'            => 'ID不能为空',
        'id.number'             => 'ID只能是正整数',
        'id.max'                => 'ID长度不能超出10位',
        'name.require'          => '名称不能为空',
        'name.max'              => '名称长度不能超出100位',
        'ruleId.require'        => '规则不能为空',
        'ruleId.array'          => '规则数据类型出现异常',
        'status.require'        => '状态不能为空',
        'status.in'             => '状态不在选项内'
    ];

    /**
     * 添加【保存】
     */
    protected function sceneAddSave()
    {
        return $this->only([
            'name', 'status', 'ruleId'
        ])->remove([
            'ruleId' => 'require'
        ]);
    }

    /**
     * ID
     */
    protected function sceneId()
    {
        return $this->only([
            'id'
        ]);
    }

    /**
     * 编辑【保存】
     */
    protected function sceneEditSave()
    {
        return $this->only([
            'id', 'name', 'status', 'ruleId'
        ])->remove([
            'ruleId' => 'require'
        ]);
    }

}